package tq.com.tqcom.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.GridView;

import tq.com.tqcom.R;

public class TQGrideView extends GridView {
    private int type = 0;
    public TQGrideView(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray lTypedArray = context.obtainStyledAttributes(attrs, R.styleable.TQGrideView);
        type = lTypedArray.getInt(R.styleable.TQGrideView_TQGrideView_ori, 0);
        lTypedArray.recycle();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                MeasureSpec.AT_MOST);
        if(type == 1){
            super.onMeasure(expandSpec, heightMeasureSpec);
        }else{
            super.onMeasure(widthMeasureSpec, expandSpec);
        }

    }
}
